﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Final_exam
{
    public class DbHepler
    {
        private static readonly string conString = "server=.;database=Schools;uid=sa;pwd=0520wst..";

        public static DataTable GetDataTable(string sql) 
        {
            SqlConnection connection = new SqlConnection(conString);

            SqlDataAdapter adapter = new SqlDataAdapter(sql,connection);

            DataTable dt = new DataTable();

            adapter.Fill(dt);

            return dt;
        }

        public static int AddUpdateordelete(string sql)
        {
            SqlConnection con = new SqlConnection(conString);

            con.Open();

            SqlCommand cod = new SqlCommand(sql, con);

            return cod.ExecuteNonQuery();

        }
    }
}
